var BASE_URL = 'http://jinzhidata.com/v2'

$(function () {
    // 加载我发布的报告/资料 todo 此处一次性加载所有的，待修改
    var url = window.location.href
    var resourceListFrom = new RegExp(BASE_URL + "/user_resource_list\\.html\\?type=(.*)").exec(url)[1]
    $.ajax({
        url: BASE_URL + "/resource/list/" + resourceListFrom,
        type: "get",
        contentType: 'application/json',
        dataType: "json",
        success: function (response) {
            if (response.code === 0) {
                var data = response.data
                var html = '';
                for (var i = 0; i < data.length; i++) {
                    html += '<li class="list_box">';
                    html += '<div class="list_info">'
                    html += '<div class="jg_logo">'
                    html += '<a href="' + BASE_URL + "/resource.html?resourceId=" + data[i].resourceId + '">'
                    html += '<img src="/img/' + data[i].resourceCover + '"/>';
                    html += '</a>';
                    html += "<dl>";
                    html += '<dt><a href="' + BASE_URL + "/resource.html?resourceId=" + data[i].resourceId + '">' + data[i].resourceName + '</a></dt>'
                    html += '<dd>积分：<a href="#">' + data[i].resourcePrice + '</a></dd>'
                    html += "</dl>";
                    html += "</div>";
                    html += "</div>";
                    html += "</li>";
                }
                $(".school_sc>ul").html(html)
            } else if (response.code === 1001) {
                alert("您还没有登录！")
                location.href = BASE_URL + "/user.html"
            } else {
                alert(response.msg)
            }
        }
    })
})

